// 路由-相关模块
import Vue from 'vue'
import VueRouter from 'vue-router' // 1.导入路由
import Layout from '@/views/Layout'
import Home from '@/views/Home'
import Play from '@/views/Play'
import Search from '@/views/Search'
Vue.use(VueRouter)  // 2.使用路由插件 // 在vue中，使用使用vue的插件，都需要调用Vue.use()
const routes = [ // 3.创建路由规则数组
  {
    path: '/',
    redirect: '/layout'
  },
  {
    path: '/layout',
    component: Layout,
    redirect: '/layout/home',
    children: [
      {
        path: 'home',
        component: Home,
        meta: { // meta保存路由对象额外信息的
          title: "首页"
        }
      },
      {
        path: 'search',
        component: Search,
        meta: {
          title: "搜索"
        }

      },

    ]

  },
  {
    path: '/play',
    component: Play,

  }

]
// 4. 创建路由对象 -  传入规则
const router = new VueRouter({
  routes
})
// 导出路由
export default router